$(function(){
	
	$("#zhaoGongZuoBut").click(function(){
		$("#zhaoGongZuoLogin").show();
		$("#zhaoRenLogin").hide();
		$(".tab_active").animate({left:"0px"});
		$("#zhaoRenBut").removeClass("active");
		$("#zhaoGongZuoBut").addClass("active");
	});
	
	$("#zhaoRenBut").click(function(){
		$("#zhaoRenLogin").show();
		$("#zhaoGongZuoLogin").hide();
		$(".tab_active").animate({left:"145px"});
		$("#zhaoGongZuoBut").removeClass("active");
		$("#zhaoRenBut").addClass("active");
	});
	loadAlter();
	
	$("#alterBut").click(function(){
		$(".alterDiv").hide();
	});
});

function loadAlter(){
	var alterCon = $("#alterContent").text();
	if(alterCon!=""){
		$(".alterDiv").show();
		var interval = setInterval(function(){
			$(".alterDiv").hide();
			$("#alterContent").text("");
			clearInterval(interval);
		},3000);
	}
	$("#alterBut").click(function(){
		$(".alterDiv").hide();
	});
}

function checkUserRegister(){
	//用户注册
	if(checkUserBasic_phone() && checkUserBasic_email() && checkUserBasic_card() && checkUserBasic_password() && checkUserBasic_password2()){
		return true;
	}
	return false;
}

function checkUserBasic_phone(){
	//检查求职者  手机号
	var userBasic_phone = $("#userBasic_phone").val();
	var reg_tel = /^1(3|4|5|6|7|8|9)\d{9}$/;
	var flag = reg_tel.test(userBasic_phone);
	if (flag) {
		$("#userBasic_phone").css("border", "");
	} else {
		$("#userBasic_phone").css("border", "1px solid red");
		$("#alterContent").html("请检查手机格式是否正确！！！");
		loadAlter();
	}
	// 4.返回校验是否通过
	return flag;
}
function checkUserBasic_email(){
	//求职者邮箱
	var userBasic_email = $("#userBasic_email").val();
	// 2.定义正则 itcast@163.com
	var reg_tel = /^\w+@\w+\.\w+$/;
	var flag = reg_tel.test(userBasic_email);
	if (flag) {
		$("#userBasic_email").css("border", "");
	} else {
		$("#userBasic_email").css("border", "1px solid red");
		$("#alterContent").html("请检查邮箱格式是否正确！！！");
		loadAlter();
	}
	// 4.返回校验是否通过
	return flag;
}
function checkUserBasic_card(){
	// 求职者  身份证
	var userBasic_card = $("#userBasic_card").val();
	var reg_tel = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)/;
	var flag = reg_tel.test(userBasic_card);
	if (flag) {
		$("#userBasic_card").css("border", "");
	} else {
		$("#userBasic_card").css("border", "1px solid red");
		$("#alterContent").html("请检查身份证格式是否正确！！！");
		loadAlter();
	}
	// 4.返回校验是否通过
	return flag;
}
function checkUserBasic_password(){
	//求职者密码
	var userBasic_password = $("#userBasic_password").val();
	if (userBasic_password.length < 6 || userBasic_password.length > 20) {
		// 密码非法,加一个红色边框
		$("#userBasic_password").css("border", "1px solid red");
		$("#alterContent").html("密码长度不能小于6位，且不能大于20位！！！");
		loadAlter();
		return false;
	} else {
		// 密码合法
		$("#userBasic_password").css("border", "");
		return true;
	}
}
function checkUserBasic_password2(){
	//求职者二次
	var userBasic_password2 = $("#userBasic_password2").val();
	var userBasic_password = $("#userBasic_password").val();
	if(userBasic_password2!=userBasic_password){
		$("#userBasic_password2").css("border", "1px solid red");
		$("#userBasic_password").css("border", "1px solid red");
		$("#alterContent").html("两次密码要一至哦！！！");
		loadAlter();
		return false;
	}else{
		$("#userBasic_password2").css("");
		$("#userBasic_password").css("");
		return true;
	}
}
function checkAttractRegister(){
	//求职者注册
	if(checkAttractRecruiter_phone() && checkAttractRecruiter_email() && checkAttractRecruiter_card() && checkAttractRecruiter_ps() && checkAttractRecruiter_ps2()){
		return true;
	}
	return false;
}


function checkAttractRecruiter_phone(){
	//招聘者  手机号
	var attractRecruiter_phone = $("#attractRecruiter_phone").val();
	var reg_tel = /^1(3|4|5|6|7|8|9)\d{9}$/;
	var flag = reg_tel.test(attractRecruiter_phone);
	if (flag) {
		$("#attractRecruiter_phone").css("border", "");
	} else {
		$("#attractRecruiter_phone").css("border", "1px solid red");
		$("#alterContent").html("请检查手机格式是否正确！！！");
		loadAlter();
	}
	// 4.返回校验是否通过
	return flag;
}
function checkAttractRecruiter_email(){
	//招聘者  邮箱
	var attractRecruiter_email = $("#attractRecruiter_email").val();
	// 2.定义正则 itcast@163.com
	var reg_tel = /^\w+@\w+\.\w+$/;
	var flag = reg_tel.test(attractRecruiter_email);
	if (flag) {
		$("#attractRecruiter_email").css("border", "");
	} else {
		$("#attractRecruiter_email").css("border", "1px solid red");
		$("#alterContent").html("请检查邮箱格式是否正确！！！");
		loadAlter();
	}
	// 4.返回校验是否通过
	return flag;
}
function checkAttractRecruiter_card(){
	//招聘者 身份证
	var attractRecruiter_card = $("#attractRecruiter_card").val();
	var reg_tel = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)/;
	var flag = reg_tel.test(attractRecruiter_card);
	if (flag) {
		$("#attractRecruiter_card").css("border", "");
	} else {
		$("#attractRecruiter_card").css("border", "1px solid red");
		$("#alterContent").html("请检查身份证格式是否正确！！！");
		loadAlter();
	}
	// 4.返回校验是否通过
	return flag;
}

function checkAttractRecruiter_ps(){
	//招聘者密码
	var attractRecruiter_ps = $("#attractRecruiter_ps").val();
	if (attractRecruiter_ps.length < 6 || attractRecruiter_ps.length > 20) {
		// 密码非法,加一个红色边框
		$("#attractRecruiter_ps").css("border", "1px solid red");
		$("#alterContent").html("密码长度不能小于6位，且不能大于20位！！！");
		loadAlter();
		return false;
	} else {
		// 密码合法
		$("#attractRecruiter_ps").css("border", "");
		return true;
	}
}
function checkAttractRecruiter_ps2(){
	//招聘者二次
	var attractRecruiter_ps2 = $("#attractRecruiter_ps2").val();
	var attractRecruiter_ps = $("#attractRecruiter_ps").val();
	if(attractRecruiter_ps2!=attractRecruiter_ps){
		$("#attractRecruiter_ps2").css("border", "1px solid red");
		$("#attractRecruiter_ps").css("border", "1px solid red");
		$("#alterContent").html("两次密码要一至哦！！！");
		loadAlter();
		return false;
	}else{
		$("#attractRecruiter_ps2").css("");
		$("#attractRecruiter_ps").css("");
		return true;
	}
}